home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / tex / lindner / texware.zoo / source / tftopl / tftopl.lzh / TFTOPL.C next >
Encoding:
C/C++ Source or Header  |  1990-05-21  |  30.6 KB  |  1,485 lines

  1. #define banner "This is TFtoPL, Version 3.1"
  2. #line 12 "g:\virtfont\tftopl.ch"
  3.  
  4. #define local_banner "Atari ST Version 1.0, May 21, 1990 by S. Lindner"
  5. #line 66 "g:\virtfont\tftopl.web"
  6.  
  7. #define NAME_LENGTH 120
  8. #define odd(a)((a)&0x1)
  9. #define tfm_size 30000
  10. #define lig_size 5000
  11. #define hash_size 5003 \
  12.  \
  13.  
  14. #define incr(a)(a)++
  15. #define decr(a)(a)--
  16. #define do_nothing  \
  17.  
  18. #define no_tag 0
  19. #define lig_tag 1
  20. #define list_tag 2
  21. #define ext_tag 3 \
  22.  
  23. #define stop_flag 128
  24. #define kern_flag 128 \
  25.  
  26. #define tfm(a)internal_tfm[a+1000] \
  27.  
  28. #define pabort(a){fprintf(output,"%s\n",a); \
  29. fprintf(output,"%s\n","Sorry, but I can't go on; are you sure this is a TFM?"); \
  30. goto final_end; \
  31. }
  32. #define pabortp(a,b){fprintf(output,"%s\n",a,b); \
  33. fprintf(output,"%s\n","Sorry, but I can't go on; are you sure this is a TFM?"); \
  34. goto final_end; \
  35. }
  36. #define pabortpp(a,b,c){fprintf(output,"%s\n",a,b,c); \
  37. fprintf(output,"%s\n","Sorry, but I can't go on; are you sure this is a TFM?"); \
  38. goto final_end; \
  39. } \
  40.  
  41. #define eval_two_bytes(a){if(tfm(tfm_ptr)>127) \
  42. pabort("One of the subfile sizes is negative!"); \
  43.  \
  44. a= tfm(tfm_ptr)*0400+tfm(tfm_ptr+1); \
  45. tfm_ptr+= 2; \
  46. } \
  47.  
  48. #define check_sum 24
  49. #define design_size check_sum+4
  50. #define scheme design_size+4
  51. #define family scheme+40
  52. #define random_word family+20
  53. #define char_info(a)4*(char_base+a)
  54. #define width_index(a)tfm(char_info(a))
  55. #define nonexistent(a)((a<bc)||(a>ec)||(width_index(a)==0))
  56. #define height_index(a)(tfm(char_info(a)+1)/16)
  57. #define depth_index(a)(tfm(char_info(a)+1)%16)
  58. #define italic_index(a)(tfm(char_info(a)+2)/4)
  59. #define tag(a)(tfm(char_info(a)+2)%4)
  60. #define reset_tag(a)tfm(char_info(a)+2)= 4*italic_index(a)+no_tag
  61. #define remainder(a)tfm(char_info(a)+3)
  62. #define width(a)4*(width_base+width_index(a))
  63. #define height(a)4*(height_base+height_index(a))
  64. #define depth(a)4*(depth_base+depth_index(a))
  65. #define italic(a)4*(italic_base+italic_index(a))
  66. #define exten(a)4*(exten_base+remainder(a))
  67. #define lig_step(a)4*(lig_kern_base+(a))
  68. #define kern(a)4*(kern_base+a)
  69. #define param(a)4*(param_base+a) \
  70.  
  71. #define vanilla 0
  72. #define mathsy 1
  73. #define mathex 2 \
  74.  
  75. #define out(a)fprintf(pl_file,a)
  76. #define outc(a)putc(a,pl_file)
  77. #define outl(a)fprintf(pl_file,"%ld",(long)(a)) \
  78.  
  79. #define bad(a){perfect= false;if(chars_on_line>0)fprintf(output," \n"); \
  80. chars_on_line= 0;fprintf(output,"Bad TFM file: %s",a); \
  81. }
  82. #define badp(a,b){perfect= false;if(chars_on_line>0)fprintf(output," \n"); \
  83. chars_on_line= 0;fprintf(output,"Bad TFM file: ");fprintf(output,a,b); \
  84. }
  85. #define badpp(a,b,c){perfect= false;if(chars_on_line>0)fprintf(output," \n"); \
  86. chars_on_line= 0;fprintf(output,"Bad TFM file: ");fprintf(output,a,b,c); \
  87. } \
  88.  
  89. #define range_error(a){perfect= false; \
  90. fprintf(output," \n%s index for character ",a); \
  91. print_octal(c);fprintf(output,"%s\n"," is too large;"); \
  92. fprintf(output,"%s\n","so I reset it to zero."); \
  93. }
  94. #define bad_char(a,b){perfect= false;if(chars_on_line>0)fprintf(output,"%s\n"," "); \
  95. chars_on_line= 0;fprintf(output,"Bad TFM file: %ld nonexistent character ",(long)(a)); \
  96. print_octal(b);fprintf(output,".\n"); \
  97. }
  98. #define correct_bad_char(a,b){perfect= false; \
  99. if(chars_on_line>0)fprintf(output,"%s\n"," "); \
  100. chars_on_line= 0;fprintf(output,"Bad TFM file: %ld nonexistent character ",(long)a); \
  101. print_octal(tfm(b));fprintf(output,".\n");tfm(b)= bc; \
  102. } \
  103.  
  104. #define bad_design(a){bad("Design size "a"!"); \
  105.  \
  106. fprintf(output,"%s\n","I've set it to 10 points."); \
  107. out(" D 10"); \
  108. } \
  109.  
  110. #define check_fix(a,b)if((tfm(a)>0)&&(tfm(a)<255)) \
  111. {tfm(a)= 0;tfm((a)+1)= 0;tfm((a)+2)= 0;tfm((a)+3)= 0; \
  112. badpp("%s %ld is too big;",b,(long)i); \
  113. fprintf(output,"%s\n","I have set it to zero."); \
  114. } \
  115.  
  116. #define nonzero_fix(a)(tfm(a)>0)||(tfm(a+1)>0)||(tfm(a+2)>0)||(tfm(a+3)>0) \
  117.  
  118. #define unreachable 0
  119. #define pass_through 1
  120. #define accessible 2 \
  121.  
  122. #define simple 0
  123. #define left_z 1
  124. #define right_z 2
  125. #define both_z 3
  126. #define pending 4 \
  127.  
  128. /*2:*/
  129. #line 79 "g:\virtfont\tftopl.web"
  130.  
  131. #include <stdio.h>
  132. #include <stdlib.h>
  133. #include <string.h>
  134. #include "portab.h"
  135.  
  136. FILE*output= stdout;
  137. char tfm_name[NAME_LENGTH],pl_name[NAME_LENGTH],output_name[NAME_LENGTH];
  138.  
  139. /*5:*/
  140. #line 115 "g:\virtfont\tftopl.web"
  141.  
  142. typedef UWORD tfm_size_type;
  143. typedef UWORD lig_size_type;
  144. typedef UWORD hash_size_type;
  145.  
  146. /*:5*//*19:*/
  147. #line 439 "g:\virtfont\tftopl.web"
  148.  
  149. typedef UBYTE byte;
  150. typedef tfm_size_type index;
  151.  
  152. /*:19*/
  153. #line 88 "g:\virtfont\tftopl.web"
  154.  
  155. /*7:*/
  156. #line 140 "g:\virtfont\tftopl.web"
  157.  
  158. FILE*tfm_file;
  159.  
  160. /*:7*//*9:*/
  161. #line 182 "g:\virtfont\tftopl.web"
  162.  
  163. UWORD lf,lh,bc,ec,nw,nh,nd,ni,nl,nk,ne,np;
  164.  
  165.  
  166. /*:9*//*17:*/
  167. #line 425 "g:\virtfont\tftopl.web"
  168.  
  169. FILE*pl_file;
  170.  
  171. /*:17*//*21:*/
  172. #line 446 "g:\virtfont\tftopl.web"
  173.  
  174. byte internal_tfm[tfm_size+1002];
  175.  
  176.  
  177. /*:21*//*24:*/
  178. #line 538 "g:\virtfont\tftopl.web"
  179.  
  180. LONG char_base,width_base,height_base,depth_base,italic_base,
  181. lig_kern_base,kern_base,exten_base,param_base;
  182.  
  183.  
  184. /*:24*//*27:*/
  185. #line 594 "g:\virtfont\tftopl.web"
  186.  
  187. UBYTE font_type;
  188.  
  189. /*:27*//*29:*/
  190. #line 613 "g:\virtfont\tftopl.web"
  191.  
  192. char ASCII_04[33],
  193. ASCII_10[33],
  194. ASCII_14[33];
  195.  
  196. char MBL_string[4],
  197. RI_string[4],
  198. RCE_string[4];
  199.  
  200.  
  201. /*:29*//*31:*/
  202. #line 632 "g:\virtfont\tftopl.web"
  203.  
  204. UBYTE dig[12];
  205.  
  206. /*:31*//*34:*/
  207. #line 669 "g:\virtfont\tftopl.web"
  208.  
  209. UWORD level;
  210.  
  211. /*:34*//*47:*/
  212. #line 854 "g:\virtfont\tftopl.web"
  213.  
  214. UBYTE chars_on_line;
  215. boolean perfect;
  216.  
  217. /*:47*//*49:*/
  218. #line 890 "g:\virtfont\tftopl.web"
  219.  
  220. UWORD i;
  221. UWORD c;
  222. UBYTE d;
  223. index k;
  224. UWORD r;
  225. UBYTE count;
  226.  
  227. /*:49*//*65:*/
  228. #line 1112 "g:\virtfont\tftopl.web"
  229.  
  230. struct{
  231. UWORD cc;
  232. lig_size_type rr;
  233. }label_table[259];
  234. UWORD label_ptr;
  235. UWORD sort_ptr;
  236. UWORD boundary_char;
  237. UWORD bchar_label;
  238.  
  239. /*:65*//*67:*/
  240. #line 1133 "g:\virtfont\tftopl.web"
  241.  
  242. UBYTE activity[lig_size+1];
  243. lig_size_type ai,acti;
  244.  
  245. /*:67*//*91:*/
  246. #line 1488 "g:\virtfont\tftopl.web"
  247.  
  248. LONG hash[hash_size+1];
  249. UBYTE class[hash_size+1];
  250. UWORD lig_z[hash_size+1];
  251. hash_size_type hash_ptr;
  252. hash_size_type hash_list[hash_size+1];
  253. hash_size_type h,hh;
  254. UWORD x_lig_cycle,y_lig_cycle;
  255.  
  256. /*:91*/
  257. #line 89 "g:\virtfont\tftopl.web"
  258.  
  259. void initialize(void)
  260. {if(output_name[0]!='\0'){
  261. output= fopen(output_name,"w");
  262. if(output==NULL){
  263. fprintf(stderr,"I can't open log file \"%s\"\n",output_name);
  264. fprintf(stderr,"The output will appear on the terminal\n");
  265. output= stdout;
  266. }
  267. }
  268. fprintf(output,"%s\n",banner);
  269. fprintf(output,"%s\n",local_banner);
  270. /*8:*/
  271. #line 149 "g:\virtfont\tftopl.web"
  272.  
  273. tfm_file= fopen(tfm_name,"rb");
  274. if(tfm_file==NULL){
  275. fprintf(stderr,"I can't open TFM file \"%s\"\n",tfm_name);
  276. exit(1);
  277. }
  278.  
  279. /*:8*//*18:*/
  280. #line 428 "g:\virtfont\tftopl.web"
  281.  
  282. pl_file= fopen(pl_name,"w");
  283. if(pl_file==NULL){
  284. fprintf(stderr,"I can't open the PL file \"%s\"\n",pl_name);
  285. exit(1);
  286. }
  287.  
  288. /*:18*//*30:*/
  289. #line 623 "g:\virtfont\tftopl.web"
  290.  
  291. strcpy(ASCII_04+1," !\"#$%&'()*+,-./0123456789:;<=>?");
  292. strcpy(ASCII_10+1,"â•ħABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_");
  293. strcpy(ASCII_14+1,"`abcdefghijklmnopqrstuvwxyz{|}~ ");
  294. strcpy(MBL_string+1,"MBL");strcpy(RI_string+1,"RI ");
  295. strcpy(RCE_string+1,"RCE");
  296.  
  297. /*:30*//*35:*/
  298. #line 672 "g:\virtfont\tftopl.web"
  299.  
  300. level= 0;
  301.  
  302. /*:35*//*48:*/
  303. #line 858 "g:\virtfont\tftopl.web"
  304.  
  305. chars_on_line= 0;
  306. perfect= true;
  307.  
  308. /*:48*//*66:*/
  309. #line 1122 "g:\virtfont\tftopl.web"
  310.  
  311. boundary_char= 256;bchar_label= (UWORD)(077777L);
  312. label_ptr= 0;label_table[0].rr= 0;
  313.  
  314. /*:66*/
  315. #line 101 "g:\virtfont\tftopl.web"
  316.  
  317. }
  318.  
  319. /*:2*//*32:*/
  320. #line 638 "g:\virtfont\tftopl.web"
  321. void out_digs(LONG j)
  322. {do{decr(j);outc('0'+dig[j]);
  323. }
  324. while(j!=0);
  325. }
  326.  
  327. void print_digs(LONG j)
  328. {do{decr(j);putc('0'+dig[j],output);
  329. }
  330. while(j!=0);
  331. }
  332.  
  333. /*:32*//*33:*/
  334. #line 654 "g:\virtfont\tftopl.web"
  335. void print_octal(byte c)
  336. {
  337. UBYTE j;
  338.  
  339. putc('\'',output);
  340. for(j= 0;j<=2;j++)
  341. {dig[j]= c%8;c= c/8;
  342. }
  343. print_digs(3);
  344. }
  345.  
  346. /*:33*//*36:*/
  347. #line 678 "g:\virtfont\tftopl.web"
  348. void out_ln(void)
  349. {
  350. UBYTE l;
  351.  
  352. putc('\n',pl_file);
  353. for(l= 1;l<=level;l++)out("   ");
  354. }
  355.  
  356. void left(void)
  357. {incr(level);outc('(');
  358. }
  359.  
  360. void right(void)
  361. {decr(level);outc(')');out_ln();
  362. }
  363.  
  364. /*:36*//*37:*/
  365. #line 698 "g:\virtfont\tftopl.web"
  366. void out_BCPL(index k)
  367. {
  368. UBYTE l;
  369.  
  370. outc(' ');l= tfm(k);
  371. while(l>0){
  372. incr(k);decr(l);
  373. switch(tfm(k)/040){
  374. case 1:outc(ASCII_04[1+(tfm(k)%040)]);break;
  375. case 2:outc(ASCII_10[1+(tfm(k)%040)]);break;
  376. case 3:outc(ASCII_14[1+(tfm(k)%040)]);break;
  377. }
  378. }
  379. }
  380.  
  381. /*:37*//*38:*/
  382. #line 719 "g:\virtfont\tftopl.web"
  383. void out_octal(index k,index l)
  384. {
  385. UWORD a;
  386. UBYTE b;
  387. UBYTE j;
  388.  
  389. out(" O ");
  390. a= 0;b= 0;j= 0;
  391. while(l>0)/*39:*/
  392. #line 734 "g:\virtfont\tftopl.web"
  393.  
  394. {decr(l);
  395. if(tfm(k+l)!=0)
  396. {while(b>2)
  397. {dig[j]= a%8;a= a/8;b= b-3;incr(j);
  398. }
  399. switch(b){
  400. case 0:a= tfm(k+l);break;
  401. case 1:a= a+2*tfm(k+l);break;
  402. case 2:a= a+4*tfm(k+l);break;
  403. }
  404. }
  405. b= b+8;
  406. }
  407.  
  408. /*:39*/
  409. #line 727 "g:\virtfont\tftopl.web"
  410. ;
  411. while((a>0)||(j==0))
  412. {dig[j]= a%8;a= a/8;incr(j);
  413. }
  414. out_digs(j);
  415. }
  416.  
  417. /*:38*//*40:*/
  418. #line 754 "g:\virtfont\tftopl.web"
  419. void out_char(byte c)
  420. {if(font_type>vanilla)
  421. {tfm(0)= c;out_octal(0,1);
  422. }
  423. else if((c>='0')&&(c<='9')){
  424. out(" C ");outc(c);}
  425. else if((c>='A')&&(c<='Z')){
  426. out(" C ");outc(ASCII_10[c-'A'+2]);}
  427. else if((c>='a')&&(c<='z')){
  428. out(" C ");outc(ASCII_14[c-'a'+2]);}
  429. else{tfm(0)= c;out_octal(0,1);
  430. }
  431. }
  432.  
  433. /*:40*//*41:*/
  434. #line 771 "g:\virtfont\tftopl.web"
  435. void out_face(index k)
  436. {
  437. UBYTE s;
  438. UBYTE b;
  439.  
  440. if(tfm(k)>=18)out_octal(k,1);
  441. else{out(" F ");
  442. s= tfm(k)%2;b= tfm(k)/2;
  443. outc(MBL_string[1+(b%3)]);
  444. outc(RI_string[1+s]);
  445. outc(RCE_string[1+(b/3)]);
  446. }
  447. }
  448.  
  449. /*:41*//*42:*/
  450. #line 792 "g:\virtfont\tftopl.web"
  451. void out_fix(index k)
  452. {
  453. UWORD a;
  454. LONG f;
  455. UBYTE j;
  456. LONG delta;
  457.  
  458. out(" R ");
  459. a= (tfm(k)*16)+(tfm(k+1)/16);
  460. f= ((long)(tfm(k+1)%16)*0400+tfm(k+2))*0400+tfm(k+3);
  461. if(a>03777)/*45:*/
  462. #line 828 "g:\virtfont\tftopl.web"
  463.  
  464. {outc('-');a= 010000-a;
  465. if(f>0)
  466. {f= 04000000L-f;decr(a);
  467. }
  468. }
  469.  
  470. /*:45*/
  471. #line 802 "g:\virtfont\tftopl.web"
  472. ;
  473. /*43:*/
  474. #line 809 "g:\virtfont\tftopl.web"
  475.  
  476. {j= 0;
  477. do{dig[j]= a%10;a= a/10;incr(j);
  478. }
  479. while(a!=0);
  480. out_digs(j);
  481. }
  482.  
  483. /*:43*/
  484. #line 803 "g:\virtfont\tftopl.web"
  485. ;
  486. /*44:*/
  487. #line 820 "g:\virtfont\tftopl.web"
  488.  
  489. {outc('.');f= 10*f+5;delta= 10;
  490. do{if(delta>04000000L)f= f+02000000L-(delta/2);
  491. outl(f/04000000L);f= 10*(f%04000000L);delta= delta*10;
  492. }
  493. while(f>delta);
  494. }
  495.  
  496. /*:44*/
  497. #line 804 "g:\virtfont\tftopl.web"
  498. ;
  499. }
  500.  
  501. /*:42*//*54:*/
  502. #line 943 "g:\virtfont\tftopl.web"
  503. void check_BCPL(index k,index l)
  504. {
  505. index j;
  506. byte c;
  507.  
  508. if(tfm(k)>=l)
  509. {bad("String is too long; I've shortened it drastically.");
  510.  
  511. tfm(k)= 1;
  512. }
  513. for(j= k+1;j<=k+tfm(k);j++)
  514. {c= tfm(j);
  515. if((c=='(')||(c==')'))
  516. {bad("Parenthesis in string has been changed to slash.");
  517.  
  518. tfm(j)= '/';
  519. }
  520. else if((c<' ')||(c>'~'))
  521. {bad("Nonstandard ASCII code has been blotted out.");
  522.  
  523. tfm(j)= '?';
  524. }
  525. else if((c>='a')&&(c<='z'))tfm(j)= c+'A'-'a';
  526. }
  527. }
  528.  
  529. /*:54*//*94:*/
  530. #line 1538 "g:\virtfont\tftopl.web"
  531. void hash_input(void)
  532. {
  533. UBYTE cc;
  534. UBYTE zz;
  535. UBYTE y;
  536. LONG key;
  537. LONG t;
  538.  
  539. if(hash_ptr==hash_size)return;
  540. /*95:*/
  541. #line 1564 "g:\virtfont\tftopl.web"
  542.  
  543. k= (index)(lig_step(i));y= tfm(k+1);t= tfm(k+2);cc= simple;zz= tfm(k+3);
  544. if(t>=kern_flag)zz= y;
  545. #line 18 "g:\virtfont\tftopl.ch"
  546. else{switch((int)t){
  547. #line 1568 "g:\virtfont\tftopl.web"
  548. case 0:
  549. case 6:do_nothing;break;
  550. case 5:
  551. case 11:zz= y;break;
  552. case 1:
  553. case 7:cc= left_z;break;
  554. case 2:cc= right_z;break;
  555. case 3:cc= both_z;break;
  556. }
  557. }
  558.  
  559. /*:95*/
  560. #line 1547 "g:\virtfont\tftopl.web"
  561. ;
  562. key= 256*c+y+1;h= (index)((1009*key)%hash_size);
  563. while(hash[h]>0)
  564. {if(hash[h]<=key)
  565. {if(hash[h]==key)return;
  566. t= hash[h];hash[h]= key;key= t;
  567. t= class[h];class[h]= cc;cc= t;
  568. t= lig_z[h];lig_z[h]= zz;zz= t;
  569. }
  570. if(h>0)decr(h);else h= hash_size;
  571. }
  572. hash[h]= key;class[h]= cc;lig_z[h]= zz;incr(hash_ptr);hash_list[hash_ptr]= h;
  573. }
  574.  
  575. /*:94*//*96:*/
  576. #line 1582 "g:\virtfont\tftopl.web"
  577. index f(index h,index x,index y);
  578.  
  579. index eval(index x,index y)
  580. {
  581. LONG key;
  582.  
  583. key= 256*x+y+1;h= (index)((1009*key)%hash_size);
  584. while(hash[h]>key)
  585. if(h>0)decr(h);else h= hash_size;
  586. if(hash[h]<key)return(y);
  587. else return(f(h,x,y));
  588. }
  589.  
  590. /*:96*//*97:*/
  591. #line 1598 "g:\virtfont\tftopl.web"
  592. index f(index h,index x,index y)
  593. {
  594. switch(class[h]){
  595. case simple:do_nothing;break;
  596. case left_z:class[h]= pending;lig_z[h]= eval(lig_z[h],y);class[h]= simple;
  597. break;
  598. case right_z:class[h]= pending;lig_z[h]= eval(x,lig_z[h]);class[h]= simple;
  599. break;
  600. case both_z:class[h]= pending;lig_z[h]= eval(eval(x,lig_z[h]),y);
  601. class[h]= simple;break;
  602. case pending:x_lig_cycle= x;y_lig_cycle= y;lig_z[h]= 257;class[h]= simple;
  603. break;
  604. }
  605. return(lig_z[h]);
  606. }
  607.  
  608. /*:97*//*98:*/
  609. #line 1624 "g:\virtfont\tftopl.web"
  610. boolean organize(void)
  611. {
  612. index tfm_ptr;
  613.  
  614. /*22:*/
  615. #line 466 "g:\virtfont\tftopl.web"
  616.  
  617. fread(&tfm(0),sizeof(tfm(0)),1,tfm_file);
  618. if(tfm(0)>127)pabort("The first byte of the input file exceeds 127!");
  619.  
  620. if(feof(tfm_file))pabort("The input file is only one byte long!");
  621.  
  622. fread(&tfm(1),sizeof(tfm(1)),1,tfm_file);lf= tfm(0)*0400+tfm(1);
  623. if(lf==0)
  624. pabort("The file claims to have length zero, but that's impossible!");
  625.  
  626. if(4*lf-1>tfm_size)pabort("The file is bigger than I can handle!");
  627.  
  628. for(tfm_ptr= 2;tfm_ptr<4*lf;tfm_ptr++)
  629. {if(feof(tfm_file))
  630. pabort("The file has fewer bytes than it claims!");
  631.  
  632. fread(&tfm(tfm_ptr),sizeof(tfm(tfm_ptr)),1,tfm_file);
  633. }
  634. getc(tfm_file);
  635. if(!feof(tfm_file))
  636. {fprintf(output,"%s\n","There's some extra junk at the end of the TFM file,");
  637.  
  638. fprintf(output,"%s\n","but I'll proceed as if it weren't there.");
  639. }
  640.  
  641. /*:22*/
  642. #line 1628 "g:\virtfont\tftopl.web"
  643. ;
  644. /*23:*/
  645. #line 501 "g:\virtfont\tftopl.web"
  646.  
  647. {tfm_ptr= 2;
  648. eval_two_bytes(lh);
  649. eval_two_bytes(bc);
  650. eval_two_bytes(ec);
  651. eval_two_bytes(nw);
  652. eval_two_bytes(nh);
  653. eval_two_bytes(nd);
  654. eval_two_bytes(ni);
  655. eval_two_bytes(nl);
  656. eval_two_bytes(nk);
  657. eval_two_bytes(ne);
  658. eval_two_bytes(np);
  659. if(lh<2)pabortp("The header length is only %ld!",(long)lh);
  660.  
  661. if(nl>4*lig_size)
  662. pabort("The lig/kern program is longer than I can handle!");
  663.  
  664. if((bc>ec+1)||(ec>255))pabortpp("The character code range %ld..%ld is illegal!",(long)bc,(long)ec);
  665.  
  666. if((nw==0)||(nh==0)||(nd==0)||(ni==0))
  667. pabort("Incomplete subfiles for character dimensions!");
  668.  
  669. if(ne>256)pabortp("There are %ld extensible recipes!",(long)ne);
  670.  
  671. if(lf!=6+lh+(ec-bc+1)+nw+nh+nd+ni+nl+nk+ne+np)
  672. pabort("Subfile sizes don't add up to the stated total!");
  673.  
  674. }
  675.  
  676. /*:23*/
  677. #line 1629 "g:\virtfont\tftopl.web"
  678. ;
  679. /*25:*/
  680. #line 543 "g:\virtfont\tftopl.web"
  681.  
  682. {char_base= 6+lh-bc;
  683. width_base= char_base+ec+1;
  684. height_base= width_base+nw;
  685. depth_base= height_base+nh;
  686. italic_base= depth_base+nd;
  687. lig_kern_base= italic_base+ni;
  688. kern_base= lig_kern_base+nl;
  689. exten_base= kern_base+nk;
  690. param_base= exten_base+ne-1;
  691. }
  692.  
  693. /*:25*/
  694. #line 1630 "g:\virtfont\tftopl.web"
  695. ;
  696. return(true);
  697. final_end:return(false);
  698. }
  699.  
  700. /*:98*//*99:*/
  701. #line 1637 "g:\virtfont\tftopl.web"
  702. void do_simple_things(void)
  703. {
  704. UWORD i;
  705.  
  706. /*50:*/
  707. #line 902 "g:\virtfont\tftopl.web"
  708.  
  709. {font_type= vanilla;
  710. if(lh>=12)
  711. {/*55:*/
  712. #line 971 "g:\virtfont\tftopl.web"
  713.  
  714. {check_BCPL(scheme,40);
  715. if((tfm(scheme)>=11)&&(tfm(scheme+1)=='T')&&
  716. (tfm(scheme+2)=='E')&&(tfm(scheme+3)=='X')&&
  717. (tfm(scheme+4)==' ')&&(tfm(scheme+5)=='M')&&
  718. (tfm(scheme+6)=='A')&&(tfm(scheme+7)=='T')&&
  719. (tfm(scheme+8)=='H')&&(tfm(scheme+9)==' '))
  720. {if((tfm(scheme+10)=='S')&&(tfm(scheme+11)=='Y'))font_type= mathsy;
  721. else if((tfm(scheme+10)=='E')&&(tfm(scheme+11)=='X'))font_type= mathex;
  722. }
  723. }
  724.  
  725. /*:55*/
  726. #line 905 "g:\virtfont\tftopl.web"
  727. ;
  728. if(lh>=17)
  729. {/*57:*/
  730. #line 988 "g:\virtfont\tftopl.web"
  731.  
  732. left();out("FAMILY");
  733. check_BCPL(family,20);
  734. out_BCPL(family);
  735. right()
  736.  
  737. /*:57*/
  738. #line 907 "g:\virtfont\tftopl.web"
  739. ;
  740. if(lh>=18)/*58:*/
  741. #line 994 "g:\virtfont\tftopl.web"
  742.  
  743. {left();out("FACE");out_face(random_word+3);right();
  744. for(i= 18;i<lh;i++)
  745. {left();out("HEADER D ");outl(i);
  746. out_octal(check_sum+4*i,4);right();
  747. }
  748. }
  749.  
  750. /*:58*/
  751. #line 908 "g:\virtfont\tftopl.web"
  752. ;
  753. }
  754. /*56:*/
  755. #line 983 "g:\virtfont\tftopl.web"
  756.  
  757. left();out("CODINGSCHEME");
  758. out_BCPL(scheme);
  759. right()
  760.  
  761. /*:56*/
  762. #line 910 "g:\virtfont\tftopl.web"
  763. ;
  764. }
  765. /*53:*/
  766. #line 929 "g:\virtfont\tftopl.web"
  767.  
  768. left();out("DESIGNSIZE");
  769. if(tfm(design_size)>127)bad_design("negative")
  770. else if((tfm(design_size)==0)&&(tfm(design_size+1)<16))
  771. bad_design("too small")
  772. else out_fix(design_size);
  773. right();
  774. out("(COMMENT DESIGNSIZE IS IN POINTS)");out_ln();
  775. out("(COMMENT OTHER SIZES ARE MULTIPLES OF DESIGNSIZE)");out_ln()
  776.  
  777.  
  778. /*:53*/
  779. #line 912 "g:\virtfont\tftopl.web"
  780. ;
  781. /*51:*/
  782. #line 917 "g:\virtfont\tftopl.web"
  783.  
  784. left();out("CHECKSUM");out_octal(check_sum,4);
  785. right()
  786.  
  787. /*:51*/
  788. #line 913 "g:\virtfont\tftopl.web"
  789. ;
  790. /*59:*/
  791. #line 1008 "g:\virtfont\tftopl.web"
  792.  
  793. if((lh>17)&&(tfm(random_word)>127))
  794. {left();out("SEVENBITSAFEFLAG TRUE");right();
  795. }
  796.  
  797. /*:59*/
  798. #line 914 "g:\virtfont\tftopl.web"
  799. ;
  800. }
  801.  
  802. /*:50*/
  803. #line 1641 "g:\virtfont\tftopl.web"
  804. ;
  805. /*60:*/
  806. #line 1015 "g:\virtfont\tftopl.web"
  807.  
  808. if(np>0)
  809. {left();out("FONTDIMEN");out_ln();
  810. for(i= 1;i<=np;i++)/*62:*/
  811. #line 1040 "g:\virtfont\tftopl.web"
  812.  
  813. {left();
  814. if(i==1)out("SLANT");
  815. else{check_fix(param(i),"Parameter");
  816.  
  817. /*63:*/
  818. #line 1050 "g:\virtfont\tftopl.web"
  819.  
  820. if(i<=7)switch(i){
  821. case 2:out("SPACE");break;
  822. case 3:out("STRETCH");break;
  823. case 4:out("SHRINK");break;
  824. case 5:out("XHEIGHT");break;
  825. case 6:out("QUAD");break;
  826. case 7:out("EXTRASPACE");break;
  827. }
  828. else if((i<=22)&&(font_type==mathsy))switch(i){
  829. case 8:out("NUM1");break;
  830. case 9:out("NUM2");break;
  831. case 10:out("NUM3");break;
  832. case 11:out("DENOM1");break;
  833. case 12:out("DENOM2");break;
  834. case 13:out("SUP1");break;
  835. case 14:out("SUP2");break;
  836. case 15:out("SUP3");break;
  837. case 16:out("SUB1");break;
  838. case 17:out("SUB2");break;
  839. case 18:out("SUPDROP");break;
  840. case 19:out("SUBDROP");break;
  841. case 20:out("DELIM1");break;
  842. case 21:out("DELIM2");break;
  843. case 22:out("AXISHEIGHT");break;
  844. }
  845. else if((i<=13)&&(font_type==mathex))
  846. if(i==8)out("DEFAULTRULETHICKNESS");
  847. else{out("BIGOPSPACING");outl(i-8);}
  848. else{out("PARAMETER D ");outl(i);}
  849.  
  850. /*:63*/
  851. #line 1045 "g:\virtfont\tftopl.web"
  852. ;
  853. }
  854. out_fix((index)(param(i)));right();
  855. }
  856.  
  857. /*:62*/
  858. #line 1018 "g:\virtfont\tftopl.web"
  859. ;
  860. right();
  861. }
  862. /*61:*/
  863. #line 1023 "g:\virtfont\tftopl.web"
  864.  
  865. if((font_type==mathsy)&&(np!=22))
  866. fprintf(output,"Unusual number of fontdimen parameters for a math symbols font (%ld not 22).",(long)np);
  867.  
  868. else if((font_type==mathex)&&(np!=13))
  869. fprintf(output,"Unusual number of fontdimen parameters for an extension font (%ld not 13).",(long)np);
  870.  
  871. /*:61*/
  872. #line 1021 "g:\virtfont\tftopl.web"
  873. ;
  874.  
  875. /*:60*/
  876. #line 1642 "g:\virtfont\tftopl.web"
  877. ;
  878. /*64:*/
  879. #line 1086 "g:\virtfont\tftopl.web"
  880.  
  881. if(nonzero_fix(4*width_base))bad("width[0] should be zero.");
  882.  
  883. if(nonzero_fix(4*height_base))bad("height[0] should be zero.");
  884. if(nonzero_fix(4*depth_base))bad("depth[0] should be zero.");
  885. if(nonzero_fix(4*italic_base))bad("italic[0] should be zero.");
  886. for(i= 0;i<nw;i++)check_fix(4*(width_base+i),"Width");
  887.  
  888. for(i= 0;i<nh;i++)check_fix(4*(height_base+i),"Height");
  889.  
  890. for(i= 0;i<nd;i++)check_fix(4*(depth_base+i),"Depth");
  891.  
  892. for(i= 0;i<ni;i++)check_fix(4*(italic_base+i),"Italic correction");
  893.  
  894. if(nk>0)for(i= 0;i<nk;i++)check_fix(kern(i),"Kern");
  895.  
  896.  
  897. /*:64*/
  898. #line 1643 "g:\virtfont\tftopl.web"
  899.  
  900. }
  901.  
  902. /*:99*//*100:*/
  903. #line 1648 "g:\virtfont\tftopl.web"
  904. void do_characters(void)
  905. {
  906. byte c;
  907. index k;
  908. lig_size_type ai;
  909.  
  910. /*80:*/
  911. #line 1312 "g:\virtfont\tftopl.web"
  912.  
  913. sort_ptr= 0;
  914. for(c= bc;c<=ec;c++)if(width_index(c)>0)
  915. {if(chars_on_line==8)
  916. {fprintf(output,"%s\n"," ");chars_on_line= 1;
  917. }
  918. else{if(chars_on_line>0)putc(' ',output);
  919. incr(chars_on_line);
  920. }
  921. print_octal(c);
  922. left();out("CHARACTER");out_char(c);out_ln();
  923. /*81:*/
  924. #line 1337 "g:\virtfont\tftopl.web"
  925.  
  926. {left();out("CHARWD");
  927. if(width_index(c)>=nw)range_error("Width")
  928. else out_fix((index)(width(c)));
  929. right();
  930. }
  931.  
  932. /*:81*/
  933. #line 1323 "g:\virtfont\tftopl.web"
  934. ;
  935. if(height_index(c)>0)/*82:*/
  936. #line 1344 "g:\virtfont\tftopl.web"
  937.  
  938. if(height_index(c)>=nh)range_error("Height")
  939.  
  940. else{left();out("CHARHT");out_fix((index)(height(c)));right();
  941. }
  942.  
  943. /*:82*/
  944. #line 1324 "g:\virtfont\tftopl.web"
  945. ;
  946. if(depth_index(c)>0)/*83:*/
  947. #line 1350 "g:\virtfont\tftopl.web"
  948.  
  949. if(depth_index(c)>=nd)range_error("Depth")
  950.  
  951. else{left();out("CHARDP");out_fix((index)(depth(c)));right();
  952. }
  953.  
  954. /*:83*/
  955. #line 1325 "g:\virtfont\tftopl.web"
  956. ;
  957. if(italic_index(c)>0)/*84:*/
  958. #line 1356 "g:\virtfont\tftopl.web"
  959.  
  960. if(italic_index(c)>=ni)range_error("Italic correction")
  961.  
  962. else{left();out("CHARIC");out_fix((index)(italic(c)));right();
  963. }
  964.  
  965. /*:84*/
  966. #line 1326 "g:\virtfont\tftopl.web"
  967. ;
  968. switch(tag(c)){
  969. case no_tag:do_nothing;break;
  970. case lig_tag:/*85:*/
  971. #line 1362 "g:\virtfont\tftopl.web"
  972.  
  973. {left();out("COMMENT");out_ln();
  974. i= remainder(c);
  975. r= (UWORD)(lig_step(i));
  976. if(tfm(r)>stop_flag)i= 256*tfm(r+2)+tfm(r+3);
  977. do{/*76:*/
  978. #line 1247 "g:\virtfont\tftopl.web"
  979.  
  980. {k= (index)(lig_step(i));
  981. if(tfm(k)>stop_flag)
  982. {if(256*tfm(k+2)+tfm(k+3)>=nl)
  983. bad("Ligature unconditional stop command address is too big.");
  984.  
  985. }
  986. else if(tfm(k+2)>=kern_flag)/*78:*/
  987. #line 1272 "g:\virtfont\tftopl.web"
  988.  
  989. {if(nonexistent(tfm(k+1)))if(tfm(k+1)!=boundary_char)
  990. correct_bad_char("Kern step for",k+1);
  991.  
  992. left();out("KRN");out_char(tfm(k+1));
  993. r= 256*(tfm(k+2)-kern_flag)+tfm(k+3);
  994. if(r>=nk)
  995. {bad("Kern index too large.");
  996.  
  997. out(" R 0.0");
  998. }
  999. else out_fix((index)(kern(r)));
  1000. right();
  1001. }
  1002.  
  1003. /*:78*/
  1004. #line 1254 "g:\virtfont\tftopl.web"
  1005.  
  1006. else/*79:*/
  1007. #line 1287 "g:\virtfont\tftopl.web"
  1008.  
  1009. {if(nonexistent(tfm(k+1)))if(tfm(k+1)!=boundary_char)
  1010. correct_bad_char("Ligature step for",k+1);
  1011.  
  1012. if(nonexistent(tfm(k+3)))
  1013. correct_bad_char("Ligature step produces the",k+3);
  1014.  
  1015. left();r= tfm(k+2);
  1016. if((r==4)||((r>7)&&(r!=11)))
  1017. {fprintf(output,"%s\n","Ligature step with nonstandard code changed to LIG");
  1018. r= 0;tfm(k+2)= 0;
  1019. }
  1020. if(r%4>1)outc('/');
  1021. out("LIG");
  1022. if(odd(r))outc('/');
  1023. while(r>3)
  1024. {outc('>');r= r-4;
  1025. }
  1026. out_char(tfm(k+1));out_char(tfm(k+3));right();
  1027. }
  1028.  
  1029. /*:79*/
  1030. #line 1255 "g:\virtfont\tftopl.web"
  1031. ;
  1032. if(tfm(k)>0)
  1033. if(level==1)/*77:*/
  1034. #line 1263 "g:\virtfont\tftopl.web"
  1035.  
  1036. {if(tfm(k)>=stop_flag)out("(STOP)");
  1037. else{count= 0;
  1038. for(ai= i+1;ai<=i+tfm(k);ai++)if(activity[ai]==accessible)incr(count);
  1039. out("(SKIP D ");outl(count);outc(')');
  1040. }
  1041. out_ln();
  1042. }
  1043.  
  1044. /*:77*/
  1045. #line 1257 "g:\virtfont\tftopl.web"
  1046. ;
  1047. }
  1048.  
  1049. /*:76*/
  1050. #line 1367 "g:\virtfont\tftopl.web"
  1051. ;
  1052. if(tfm(k)>=stop_flag)i= nl;
  1053. else i= i+1+tfm(k);
  1054. }while(i<nl);
  1055. right();
  1056. }
  1057.  
  1058. /*:85*/
  1059. #line 1330 "g:\virtfont\tftopl.web"
  1060. ;break;
  1061. case list_tag:/*86:*/
  1062. #line 1379 "g:\virtfont\tftopl.web"
  1063.  
  1064. {r= remainder(c);
  1065. if(nonexistent(r))
  1066. {bad_char("Character list link to",r);reset_tag(c);
  1067.  
  1068. }
  1069. else{while((r<c)&&(tag(r)==list_tag))r= remainder(r);
  1070. if(r==c)
  1071. {bad("Cycle in a character list!");
  1072.  
  1073. fprintf(output,"Character ");print_octal(c);
  1074. fprintf(output,"%s\n"," now ends the list.");
  1075. reset_tag(c);
  1076. }
  1077. else{left();out("NEXTLARGER");out_char(remainder(c));
  1078. right();
  1079. }
  1080. }
  1081. }
  1082.  
  1083. /*:86*/
  1084. #line 1331 "g:\virtfont\tftopl.web"
  1085. ;break;
  1086. case ext_tag:/*87:*/
  1087. #line 1399 "g:\virtfont\tftopl.web"
  1088.  
  1089. if(remainder(c)>=ne)
  1090. {range_error("Extensible");reset_tag(c);
  1091.  
  1092. }
  1093. else{left();out("VARCHAR");out_ln();
  1094. /*88:*/
  1095. #line 1409 "g:\virtfont\tftopl.web"
  1096.  
  1097. for(k= 0;k<=3;k++)if((k==3)||(tfm(exten(c)+k)>0))
  1098. {left();
  1099. switch(k){
  1100. case 0:out("TOP");break;
  1101. case 1:out("MID");break;
  1102. case 2:out("BOT");break;
  1103. case 3:out("REP");break;
  1104. }
  1105. if(nonexistent(tfm(exten(c)+k)))out_char(c);
  1106. else out_char(tfm(exten(c)+k));
  1107. right();
  1108. }
  1109.  
  1110. /*:88*/
  1111. #line 1405 "g:\virtfont\tftopl.web"
  1112. ;
  1113. right();
  1114. }
  1115.  
  1116. /*:87*/
  1117. #line 1332 "g:\virtfont\tftopl.web"
  1118. ;break;
  1119. }
  1120. right();
  1121. }
  1122.  
  1123. /*:80*/
  1124. #line 1654 "g:\virtfont\tftopl.web"
  1125. ;
  1126. }
  1127.  
  1128. /*:100*//*101:*/
  1129. #line 1658 "g:\virtfont\tftopl.web"
  1130.  
  1131. /*103:*/
  1132. #line 1689 "g:\virtfont\tftopl.web"
  1133.  
  1134. void append_extension(char*name,char*extension)
  1135. {
  1136. char*p;
  1137.  
  1138. p= name+strlen(name)-1;
  1139. while(p>name){
  1140. if((*p=='.')||(*p=='\\')||(*p==':'))
  1141. break;
  1142. p--;
  1143. }
  1144. if((p==name)||(*p!='.')){
  1145. strcat(name,".");
  1146. strcat(name,extension);
  1147. }
  1148. else{
  1149. p++;
  1150. if(strcmp(p,extension)!=0)
  1151. strcpy(p,extension);
  1152. }
  1153. }
  1154.  
  1155. /*:103*/
  1156. #line 1659 "g:\virtfont\tftopl.web"
  1157.  
  1158. int main(int argc,char**argv)
  1159. {
  1160. /*104:*/
  1161. #line 1712 "g:\virtfont\tftopl.web"
  1162.  
  1163. argv++;
  1164. argc--;
  1165. if(argc==0){
  1166. fprintf(stderr,"! No TFM file speciefied\n");
  1167. exit(1);
  1168. }
  1169. strcpy(tfm_name,*argv);
  1170. append_extension(tfm_name,"tfm");
  1171. argv++;
  1172. argc--;
  1173.  
  1174. if(argc!=0){
  1175. strcpy(pl_name,*argv);
  1176. argv++;
  1177. argc--;
  1178. }
  1179. else
  1180. strcpy(pl_name,tfm_name);
  1181. append_extension(pl_name,"pl");
  1182.  
  1183. /*:104*/
  1184. #line 1662 "g:\virtfont\tftopl.web"
  1185.  
  1186. initialize();
  1187. if(!organize())return(1);
  1188. do_simple_things();
  1189. /*68:*/
  1190. #line 1137 "g:\virtfont\tftopl.web"
  1191.  
  1192. if(nl>0)
  1193. {for(ai= 0;ai<nl;ai++)activity[ai]= unreachable;
  1194. /*71:*/
  1195. #line 1185 "g:\virtfont\tftopl.web"
  1196.  
  1197. if(tfm(lig_step(0))==255)
  1198. {left();out("BOUNDARYCHAR");
  1199. boundary_char= tfm(lig_step(0)+1);out_char(boundary_char);right();
  1200. activity[0]= pass_through;
  1201. }
  1202. if(tfm(lig_step(nl-1))==255)
  1203. {r= 256*tfm(lig_step(nl-1)+2)+tfm(lig_step(nl-1)+3);
  1204. if(r>=nl)
  1205. {perfect= false;fprintf(output,"%s\n"," ");
  1206. fprintf(output,"Ligature/kern starting index for boundarychar is too large;");
  1207. fprintf(output,"%s\n","so I removed it.");
  1208.  
  1209. }
  1210. else{label_ptr= 1;label_table[1].cc= 256;label_table[1].rr= r;
  1211. bchar_label= r;activity[r]= accessible;
  1212. }
  1213. activity[nl-1]= pass_through;
  1214. }
  1215.  
  1216. /*:71*/
  1217. #line 1140 "g:\virtfont\tftopl.web"
  1218. ;
  1219. }
  1220. /*69:*/
  1221. #line 1154 "g:\virtfont\tftopl.web"
  1222.  
  1223. for(c= bc;c<=ec;c++)if(tag(c)==lig_tag)
  1224. {r= remainder(c);
  1225. if(r<nl)
  1226. {if(tfm(lig_step(r))>stop_flag)
  1227. {r= 256*tfm(lig_step(r)+2)+tfm(lig_step(r)+3);
  1228. if(r<nl)if(activity[remainder(c)]==unreachable)
  1229. activity[remainder(c)]= pass_through;
  1230. }
  1231. }
  1232. if(r>=nl)
  1233. {perfect= false;fprintf(output,"%s\n"," ");
  1234. fprintf(output,"Ligature/kern starting index for character ");print_octal(c);
  1235. fprintf(output,"%s\n"," is too large;");fprintf(output,"%s\n","so I removed it.");reset_tag(c);
  1236.  
  1237. }
  1238. else/*70:*/
  1239. #line 1174 "g:\virtfont\tftopl.web"
  1240.  
  1241. {sort_ptr= label_ptr;
  1242. while(label_table[sort_ptr].rr>r)
  1243. {label_table[sort_ptr+1]= label_table[sort_ptr];
  1244. decr(sort_ptr);
  1245. }
  1246. label_table[sort_ptr+1].cc= c;
  1247. label_table[sort_ptr+1].rr= r;
  1248. incr(label_ptr);activity[r]= accessible;
  1249. }
  1250.  
  1251. /*:70*/
  1252. #line 1170 "g:\virtfont\tftopl.web"
  1253. ;
  1254. }
  1255. label_table[label_ptr+1].rr= lig_size;
  1256.  
  1257. /*:69*/
  1258. #line 1142 "g:\virtfont\tftopl.web"
  1259. ;
  1260. if(nl>0)
  1261. {left();out("LIGTABLE");out_ln();
  1262. /*72:*/
  1263. #line 1205 "g:\virtfont\tftopl.web"
  1264.  
  1265. for(ai= 0;ai<nl;ai++)if(activity[ai]==accessible)
  1266. {r= tfm(lig_step(ai));
  1267. if(r<stop_flag)
  1268. {r= r+ai+1;
  1269. if(r>=nl)
  1270. {badp("Ligature/kern step %ld skips too far;",(long)ai);
  1271.  
  1272. fprintf(output,"%s\n","I made it stop.");tfm(lig_step(ai))= stop_flag;
  1273. }
  1274. else activity[r]= accessible;
  1275. }
  1276. }
  1277.  
  1278. /*:72*/
  1279. #line 1145 "g:\virtfont\tftopl.web"
  1280. ;
  1281. /*73:*/
  1282. #line 1222 "g:\virtfont\tftopl.web"
  1283.  
  1284. sort_ptr= 1;
  1285. for(acti= 0;acti<nl;acti++)if(activity[acti]!=pass_through)
  1286. {i= acti;/*75:*/
  1287. #line 1239 "g:\virtfont\tftopl.web"
  1288.  
  1289. if(activity[i]==unreachable)
  1290. {if(level==1)
  1291. {left();out("COMMENT THIS PART OF THE PROGRAM IS NEVER USED!");out_ln();
  1292. }
  1293. }
  1294. else if(level==2)right()
  1295.  
  1296. /*:75*/
  1297. #line 1225 "g:\virtfont\tftopl.web"
  1298. ;
  1299. /*74:*/
  1300. #line 1231 "g:\virtfont\tftopl.web"
  1301.  
  1302. while(i==label_table[sort_ptr].rr)
  1303. {left();out("LABEL");
  1304. if(label_table[sort_ptr].cc==256)out(" BOUNDARYCHAR");
  1305. else out_char(label_table[sort_ptr].cc);
  1306. right();incr(sort_ptr);
  1307. }
  1308.  
  1309. /*:74*/
  1310. #line 1226 "g:\virtfont\tftopl.web"
  1311. ;
  1312. /*76:*/
  1313. #line 1247 "g:\virtfont\tftopl.web"
  1314.  
  1315. {k= (index)(lig_step(i));
  1316. if(tfm(k)>stop_flag)
  1317. {if(256*tfm(k+2)+tfm(k+3)>=nl)
  1318. bad("Ligature unconditional stop command address is too big.");
  1319.  
  1320. }
  1321. else if(tfm(k+2)>=kern_flag)/*78:*/
  1322. #line 1272 "g:\virtfont\tftopl.web"
  1323.  
  1324. {if(nonexistent(tfm(k+1)))if(tfm(k+1)!=boundary_char)
  1325. correct_bad_char("Kern step for",k+1);
  1326.  
  1327. left();out("KRN");out_char(tfm(k+1));
  1328. r= 256*(tfm(k+2)-kern_flag)+tfm(k+3);
  1329. if(r>=nk)
  1330. {bad("Kern index too large.");
  1331.  
  1332. out(" R 0.0");
  1333. }
  1334. else out_fix((index)(kern(r)));
  1335. right();
  1336. }
  1337.  
  1338. /*:78*/
  1339. #line 1254 "g:\virtfont\tftopl.web"
  1340.  
  1341. else/*79:*/
  1342. #line 1287 "g:\virtfont\tftopl.web"
  1343.  
  1344. {if(nonexistent(tfm(k+1)))if(tfm(k+1)!=boundary_char)
  1345. correct_bad_char("Ligature step for",k+1);
  1346.  
  1347. if(nonexistent(tfm(k+3)))
  1348. correct_bad_char("Ligature step produces the",k+3);
  1349.  
  1350. left();r= tfm(k+2);
  1351. if((r==4)||((r>7)&&(r!=11)))
  1352. {fprintf(output,"%s\n","Ligature step with nonstandard code changed to LIG");
  1353. r= 0;tfm(k+2)= 0;
  1354. }
  1355. if(r%4>1)outc('/');
  1356. out("LIG");
  1357. if(odd(r))outc('/');
  1358. while(r>3)
  1359. {outc('>');r= r-4;
  1360. }
  1361. out_char(tfm(k+1));out_char(tfm(k+3));right();
  1362. }
  1363.  
  1364. /*:79*/
  1365. #line 1255 "g:\virtfont\tftopl.web"
  1366. ;
  1367. if(tfm(k)>0)
  1368. if(level==1)/*77:*/
  1369. #line 1263 "g:\virtfont\tftopl.web"
  1370.  
  1371. {if(tfm(k)>=stop_flag)out("(STOP)");
  1372. else{count= 0;
  1373. for(ai= i+1;ai<=i+tfm(k);ai++)if(activity[ai]==accessible)incr(count);
  1374. out("(SKIP D ");outl(count);outc(')');
  1375. }
  1376. out_ln();
  1377. }
  1378.  
  1379. /*:77*/
  1380. #line 1257 "g:\virtfont\tftopl.web"
  1381. ;
  1382. }
  1383.  
  1384. /*:76*/
  1385. #line 1227 "g:\virtfont\tftopl.web"
  1386. ;
  1387. }
  1388. if(level==2)right()
  1389.  
  1390. /*:73*/
  1391. #line 1146 "g:\virtfont\tftopl.web"
  1392. ;
  1393. right();
  1394. /*92:*/
  1395. #line 1497 "g:\virtfont\tftopl.web"
  1396.  
  1397. hash_ptr= 0;y_lig_cycle= 256;
  1398. for(hh= 0;hh<=hash_size;hh++)hash[hh]= 0;
  1399. for(c= bc;c<=ec;c++)if(tag(c)==lig_tag)
  1400. {i= remainder(c);
  1401. if(tfm(lig_step(i))>stop_flag)
  1402. i= 256*tfm(lig_step(i)+2)+tfm(lig_step(i)+3);
  1403. /*93:*/
  1404. #line 1528 "g:\virtfont\tftopl.web"
  1405.  
  1406. do{hash_input();k= tfm(lig_step(i));
  1407. if(k>=stop_flag)i= nl;
  1408. else i= i+1+k;
  1409. }
  1410. while(i<nl);
  1411.  
  1412. /*:93*/
  1413. #line 1504 "g:\virtfont\tftopl.web"
  1414. ;
  1415. }
  1416. if(bchar_label<nl)
  1417. {c= 256;i= bchar_label;
  1418. /*93:*/
  1419. #line 1528 "g:\virtfont\tftopl.web"
  1420.  
  1421. do{hash_input();k= tfm(lig_step(i));
  1422. if(k>=stop_flag)i= nl;
  1423. else i= i+1+k;
  1424. }
  1425. while(i<nl);
  1426.  
  1427. /*:93*/
  1428. #line 1508 "g:\virtfont\tftopl.web"
  1429. ;
  1430. }
  1431. if(hash_ptr==hash_size)
  1432. {fprintf(output,"%s\n","Sorry, I haven't room for so many ligature/kern pairs!");
  1433.  
  1434. goto final_end;
  1435. }
  1436. for(hh= 1;hh<=hash_ptr;hh++)
  1437. {r= hash_list[hh];
  1438. if(class[r]>simple)
  1439. r= f(r,(index)((hash[r]-1)/256),(index)((hash[r]-1)%256));
  1440. }
  1441. if(y_lig_cycle<256)
  1442. {fprintf(output,"Infinite ligature loop starting with ");
  1443.  
  1444. if(x_lig_cycle==256)fprintf(output,"boundary");else print_octal(x_lig_cycle);
  1445. fprintf(output," and ");print_octal(y_lig_cycle);fprintf(output,"%s\n","!");
  1446. out("(INFINITE LIGATURE LOOP MUST BE BROKEN!)");goto final_end;
  1447. }
  1448.  
  1449. /*:92*/
  1450. #line 1148 "g:\virtfont\tftopl.web"
  1451. ;
  1452. }
  1453.  
  1454. /*:68*/
  1455. #line 1666 "g:\virtfont\tftopl.web"
  1456. ;
  1457. /*89:*/
  1458. #line 1427 "g:\virtfont\tftopl.web"
  1459.  
  1460. if(ne>0)for(c= 0;c<ne;c++)for(d= 0;d<=3;d++)
  1461. {k= (index)(4*(exten_base+c)+d);
  1462. if((tfm(k)>0)||(d==3))
  1463. {if(nonexistent(tfm(k)))
  1464. {bad_char("Extensible recipe involves the",tfm(k));
  1465.  
  1466. if(d<3)tfm(k)= 0;
  1467. }
  1468. }
  1469. }
  1470.  
  1471. /*:89*/
  1472. #line 1667 "g:\virtfont\tftopl.web"
  1473. ;
  1474. do_characters();fprintf(output,"%s\n",".");
  1475. if(level!=0)fprintf(output,"%s\n","This program isn't working!");
  1476.  
  1477. if(!perfect)
  1478. out("(COMMENT THE TFM FILE WAS BAD, SO THE DATA HAS BEEN CHANGED!)");
  1479.  
  1480. return(0);
  1481. final_end:return(1);
  1482. }
  1483.  
  1484. /*:101*/
  1485.